import { CallUtils } from './CallUtils';

export class TimeoutUtil {
  static timeout: number | undefined;

  static start(): void {
    // 如果30秒内没有接听或挂断，连接将会超时
    TimeoutUtil.timeout = setTimeout(() => {
      CallUtils.close();
    }, 30_000);
  }

  static stop(): void {
    if (TimeoutUtil.timeout !== undefined) {
      clearTimeout(TimeoutUtil.timeout);
      TimeoutUtil.timeout = undefined;
    }
  }
}